﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="Add_Edit.aspx.cs" Inherits="admin_Subject_Add_Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

        <div class="content-box-outer">
        <div class="content-box-full">
            <h1>
                Thêm / Cập nhật Chủ Đề</h1>
            <script type="text/javascript">
                function GetSlug() {
                    var title = document.getElementById('<%=txtName.ClientID %>').value;
                    var slug = document.getElementById('<%=txtSlug.ClientID %>');
                    slug.value = RemoveDiacriticsURL(title);
                }
                $(document).ready(function () {
                    $("#uploadImage").colorbox({ width: "550px", inline: true, href: "#uploadImagePanel" });
                    $("#uploadVideo").colorbox({ width: "550px", inline: true, href: "#uploadVideoPanel" });
                    $("#uploadFile").colorbox({ width: "550px", inline: true, href: "#uploadFilePanel" });
                    $("#contactdetail").colorbox({ width: "550px", inline: true, href: "#contactform" });
                    $("#slideanh").colorbox({ width: "650px", height: "530px", inline: true, href: "#slidePanel" });
                    $("#addslide").colorbox({ width: "650px", height: "530px", inline: true, href: "#addSlidePanel" });
                });

                function closeOverlay() {
                    $.colorbox.close();
                    return false;
                }
                $(document).ready(function () {


                    $("#<%=txtDate.ClientID %>").datepicker({
                        changeMonth: false
            , changeYear: false
            , dateFormat: 'dd/mm/yy'
            , regional: 'vi'
            , duration: 'slow'

                    });
                });

                    function ToggleTagSelector() {

                        $("#tagselector").toggle("slow");
                    }
                    function toggleAutomaticDate() {
                        var element = document.getElementById('rbtManual');
                        var panel = document.getElementById('datePanel');
                        if (element.checked) {
                            panel.style.display = "block";
                        }
                        else {
                            panel.style.display = "none";
                        }
                    }
            </script>
            <div id="panel" style="display: none; height: 1px">
                <div id="uploadVideoPanel" class="overlaypanel">
                    <h2>
                        Chèn Video</h2>
                    <ul class="fl" style="margin: 0;">
                        <li>
                            <label class="lbl">
                                Videos</label>
                            <asp:FileUpload runat="server" ID="txtUploadVideo" Width="400" size="50" ValidationGroup="imageupload" />
                            <asp:RequiredFieldValidator ID="txtUploadVideoValidator" runat="Server" ControlToValidate="txtUploadVideo"
                                ErrorMessage="Được yêu cầu" ValidationGroup="videoupload" />
                        </li>
                        <li style="margin: 0;">
                            <asp:Button runat="server" ID="btnUploadVideo" Text="Upload"
                                ValidationGroup="videoupload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('videoupload', 'uploadVideoPanel');" />
                            hoặc
                            <a href="#" onclick="return closeOverlay();">
                                Hủy</a> </li>
                    </ul>
                </div>
                <div id="uploadImagePanel" class="overlaypanel">
                    <h2>
                        Chèn ảnh</h2>
                    <ul class="fl" style="margin: 0;">
                        <li>
                            <label class="lbl">
                                Hình ảnh</label>
                            <asp:FileUpload runat="server" ID="txtUploadImage" Width="400" size="50" ValidationGroup="imageupload" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="txtUploadImage"
                                ErrorMessage="Được yêu cầu" ValidationGroup="imageupload" />
                        </li>
                        <li style="margin: 0;">
                            <asp:Button runat="server" ID="btnUploadImage" Text="Upload"
                                ValidationGroup="imageupload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('imageupload', 'uploadImagePanel');" />
                            hoặc
                            <a href="#" onclick="return closeOverlay();">
                                Hủy</a> </li>
                    </ul>
                </div>
                <div id="uploadFilePanel" class="overlaypanel">
                    <h2>
                        File đính kèm</h2>
                    <ul class="fl" style="margin: 0;">
                        <li>
                            <asp:Label ID="Label1" CssClass="lbl" AssociatedControlID="txtUploadFile" runat="server"
                                Text='Upload' />
                            <asp:FileUpload runat="server" ID="txtUploadFile" Width="400" size="50" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtUploadFile"
                                ErrorMessage="Được yêu cầu" ValidationGroup="fileUpload" />
                        </li>
                        <li style="margin: 0;">
                            <asp:Button runat="server" ID="btnUploadFile" Text="Upload"
                                ValidationGroup="fileUpload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('fileUpload', 'uploadFilePanel');" />
                            hoặc
                            <a href="#" onclick="return closeOverlay();">
                                Hủy</a> </li>
                    </ul>
                </div>
                <div id="contactform" class="overlaypanel">
                    <h2>
                        Đặc điểm Chủ Đề</h2>
                    <ul class="fl" style="margin: 0;">
                         <li style="margin: 0;">Khuyến mãi: 
                            <asp:CheckBox ID="cbIsPromotion" runat="server" />
                        </li>
                         <li style="margin: 0;">Được ưa chuộng: 
                            <asp:CheckBox ID="cbIsLike" runat="server" />
                        </li>
                        <li style="margin: 0;">Màu sắc: 
                            <asp:TextBox ID="txtColor" runat="server" Width="450"></asp:TextBox>
                        </li>
                        <li style="margin: 0;">Quy cách: 
                            <asp:TextBox ID="txtSpecifications" runat="server" Width="450"></asp:TextBox>
                        </li>
                        <li style="margin: 0;"> Giá từ:<br />
                           <asp:TextBox ID="txtPrice" runat="server" ></asp:TextBox></li>
                    <li>   Giá đến: <br />
                            <asp:TextBox ID="txtPriceMax" runat="server"></asp:TextBox>
                        </li>
                        <li style="margin: 0;">Kích thước: <br />
                            <asp:TextBox ID="txtWidth" runat="server"></asp:TextBox>
                       x
                      
                            <asp:TextBox ID="txtHeight" runat="server"></asp:TextBox></li>
                        <li style="margin: 0;">Trọng lượng: 
                            <asp:TextBox ID="txtWeight" runat="server" Width="450"></asp:TextBox>
                        </li>
                        <li style="margin: 0;">Đơn vị: 
                            <asp:TextBox ID="txtUnit" runat="server" Width="450"></asp:TextBox>
                        </li>
                       
                    </ul>
                </div>
                <div id="addSlidePanel" class="overlaypanel">
                    <h2>
                        Hình ảnh
                    </h2>
                    <ul class="fl" style="margin: 0; list-style: none">
                        <li>Bạn có thể chọn nhiều hình ảnh để làm slide cho bài viết. Không hạn chế hình ảnh.<br />
                            Nhấn vào dấu x nếu muốn bỏ chọn. (Lưu ý: File nhỏ hơn 1MB).<br />
                            Nhấn Lưu đăng bài để lưu lại. </li>
                        <li>
                            <asp:FileUpload ID="FileUpload1" runat="server" class="multi" accept="gif|jpg|png|bmp" />
                        </li>
                    </ul>
                </div>
                <div id="slidePanel" class="overlaypanel">
                    <h2>
                        Hình ảnh
                        <%if (SubjectId != -1)
                          { %>
                        <a href="#" class="delete" onclick="return deleteServiceImageByServiceID(<%=SubjectId.ToString() %>)">
                            Xóa tất cả</a><%} %>
                    </h2>
                    <ul class="fl" style="margin: 0; list-style: none">
                        <asp:Repeater ID="rptImageSlide" runat="server">
                            <ItemTemplate>
                                <li style="display: inline; margin: 5px;">
                                    <div style="width: 90px; height: 100px; float: left; border: 1px solid #3399cc; margin: 5px;
                                        text-align: center">
                                        <img src="ThumbnailHandler.axd?img=<%#Eval("ImageUrl") %>&size=64" width="64" height="64"
                                            alt="" style="padding: 5px" />
                                        <br />
                                        <a href="#" class="delete" onclick="return deleteServiceImage(<%#Eval("ImageID") %>)"
                                            style="margin: 0">Xóa</a>
                                    </div>
                                </li>
                            </ItemTemplate>
                        </asp:Repeater>
                    </ul>
                </div>
            </div>
            <table class="tblForm largeForm" style="width: 100%; margin: 0;">
                <tr>
                    <td style="vertical-align: top; padding: 0 40px 0 0;">
                        <ul class="fl">
                            <li>
                                <label class="lbl">
                                    Tên Chủ Đề</label>
                                <asp:TextBox runat="server" ID="txtName" Width="600px" onblur="GetSlug()" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                                    ErrorMessage="*" Display="Dynamic" ValidationGroup="add" />
                                &nbsp;<a href="#" id="contactdetail" class="tooltip" title="Đặc điểm sản phẩm">Đặc điểm
                                    Chủ Đề</a> </li>
                            <li>
                                <asp:TextBox runat="server" ID="txtRawContent" Width="96%" TextMode="multiLine" Height="400px"
                                    Visible="false" />
                            </li>
                            <li>
                                <div class="editToolbar" style="display: none">
                                    <asp:CheckBox runat="server" ID="cbUseRaw" Text="Plain Text" AutoPostBack="true" />
                                    <a href="#" id="uploadImage" class="image" title="Chèn ảnh">
                                        Chèn ảnh</a> <a href="#" id="uploadVideo" class="video"
                                            title="Chèn Video">
                                            Chèn Video</a> <a href="#" id="uploadFile" class="file" title=" File đính kèm">
                                                File đính kèm</a>
                                </div>
                                <label class="lbl">
                                    Nội dung</label>
                                <asp:Editor ID="txtBody" runat="server" Width="100%" Height="350" Mode="Basic" />
                            </li>
                            <li>
                                <label class="lbl">
                                    Tiêu đề thân thiện</label>
                                <asp:TextBox runat="server" ID="txtSlug" Width="600" />
                                &nbsp;<a href="javascript:void(GetSlug());" title="Từ tên"
                                    class="tooltip">
                                    Từ tên></a> </li>
                            <li>
                                <label class="lbl">
                                    Mô tả ngắn</label>
                                <asp:TextBox runat="server" ID="txtDescription" TextMode="multiLine" Columns="50"
                                    Rows="3" Width="600" Height="80" />
                            </li>
                            <li>
                                <label class="lbl">
                                    Sắp xếp
                                </label>
                                <asp:TextBox ID="txtSortIndex" runat="server"></asp:TextBox>
                            </li>
                            <li>
                                <label class="lbl">
                                    Tùy chọn</label>
                                <asp:CheckBox runat="server" ID="cbIsFrontPage" Text="Hiển thị trang chủ" Checked="true" />
                            </li>
                            <li>
                                <asp:CheckBox runat="server" ID="cbEnableComments" Text="Cho phép bình luận" Checked="true" />
                            </li>
                            <li>
                                <asp:CheckBox runat="server" ID="cbIsActive" Text="Duyệt chủ đề" Checked="true" />
                            </li>
                        </ul>
                        <div class="action_buttons">
                            <asp:Button ID="btnSave" runat="server" Text="Lưu" ValidationGroup="add"
                                CssClass="btn primary rounded" OnClick="btnSave_Click" />
                            hoặc &nbsp; <a href="Product.aspx" title="Hủy">
                                Hủy</a> <span id="autoSaveLabel" style="display: none;">
                            </span>
                        </div>
                    </td>
                    <td class="secondaryForm" style="padding: 0; vertical-align: top;">
                        <ul class="fl">
                            <li>
                                <label class="lbl">
                                    Tác giả</label>
                                <asp:DropDownList runat="Server" ID="ddlAuthor" />
                            </li>
                            <li>
                                <label class="lbl">
                                    Hình ảnh</label>
                                <div class="rounded" style="overflow-y: auto; height: 160px; max-height: 160px; border: solid 1px #dcdcdc;
                                    padding: 5px; margin: 0 0 5px; text-align: center">
                                    <img src="/uploads/images/noimage.png" width="160" height="160" runat="server" id="imgthumb"
                                        clientid="Static" alt="" />
                                </div>
                                <div>
                                    <asp:TextBox ID="txtPicture" runat="server" CssClass="txt200" Text="/uploads/images/noimage.png"></asp:TextBox>
                                    <span class="belowHelp">
                                        Ảnh đại diện cho sản phẩm</span>
                                </div>
                            </li>
                            <li>
                                <div class="action_buttons">
                                    <input id="addslide" type="button" class="btn  rounded" value="Thêm ảnh" />
                                    <input id="slideanh" type="button" class="btn primary rounded" value="Slide ảnh" />
                                </div>
                            </li>
                            <li>
                                <label class="lbl">
                                    Ngày thêm</label>
                                <input type="radio" name="PublishDate" id="rbtAuto" onclick="toggleAutomaticDate()"
                                    checked="checked" /><label for="rbtAuto">
                                        Tự động</label>
                                <input type="radio" name="PublishDate" id="rbtManual" onclick="toggleAutomaticDate()" /><label
                                    for="rbtManual">
                                    Cấu hình</label>
                                <div id="datePanel" style="display: none;">
                                    <asp:TextBox runat="server" ID="txtDate" Width="170" />
                                    <asp:TextBox runat="server" ID="txtTime" Width="50" />
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtDate"
                                        ValidationExpression="[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" ErrorMessage="Nhập ngày"
                                        Display="dynamic" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDate"
                                        ErrorMessage="Nhập ngày" Display="Dynamic" />
                                </div>
                            </li>
                            <li>
                                <label class="lbl">
                                    Danh mục</label>
                                <div class="rounded" style="overflow-y: auto; max-height: 160px; border: solid 1px #dcdcdc;
                                    padding: 5px; margin: 0 0 5px;">
                                    <span id="cblCategories" runat="server" class="cblCategories"></span>
                                    <asp:ListBox runat="server" ID="lbCategories" Height="160" AppendDataBoundItems="true">
                                    </asp:ListBox>
                                </div>
                                <div style="">
                                    <label for="<%=txtCategory.ClientID %>" style="margin-bottom: 5px; display: block;">
                                        Thêm nhanh Danh mục</label>
                                    <asp:TextBox runat="server" ID="txtCategory" ValidationGroup="category" Width="150" />
                                    <asp:Button runat="server" ID="btnCategory" Text="Thêm" ValidationGroup="category"
                                        CssClass="btn" Style="min-width: 0px; margin: 0;" OnClick="btnCategory_Click" />
                                    <asp:CustomValidator runat="Server" ID="valExist" ValidationGroup="category" ControlToValidate="txtCategory"
                                        ErrorMessage="Chuyên mục đã tồn tại" Display="dynamic" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtCategory"
                                        ErrorMessage="*" ValidationGroup="category" Display="Dynamic" />
                                </div>
                            </li>
                            <li style="position: relative;">
                                <label class="lbl">
                                    Tags</label>
                                <asp:TextBox runat="server" ID="txtTags" TextMode="MultiLine" Rows="3" />
                                <span>
                                    Các tag cách nhau bởi dấu phẩy
                                </span>
                                hoặc
                                <a href="javascript:void(ToggleTagSelector())" class="tooltip" title="chọn từ khóa có sẵn">
                                    Chọn tags đã có</a>
                                <div id="tagselector" class="rounded" style="display: none;">
                                    <a class="close" onclick="ToggleTagSelector()"></a><span>blog</span>
                                    <div class="clear">
                                    </div>
                                    <div style="max-height: 150px; overflow-y: auto;">
                                        <asp:PlaceHolder runat="server" ID="phTags" />
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <script type="text/javascript">
        $(document).ready(function () {
            var thumb = jQuery("img#<%=imgthumb.ClientID %>");
            var txtPicture = jQuery("#<%=txtPicture.ClientID %>");
            txtPicture.blur(function () {
                thumb.attr('src', txtPicture.val());
            });
        });
    </script>
    <script type="text/javascript">
        jQuery(document).ready(function () {
            var thumb = jQuery("img#<%=imgthumb.ClientID %>");
            var txtPicture = jQuery("#<%=txtPicture.ClientID %>");
            new AjaxUpload(thumb, {

                action: '/ImageUpload.axd',
                name: 'myFile',
                onSubmit: function (file, extension) {
                    if (!(extension && /^(jpg|png|jpeg|gif|bmp|JPG|PNG|JPEG|BMP|GIF)$/.test(extension))) {

                        alert('Only JPG, PNG or GIF files are allowed');
                        return false;
                    }

                    thumb.attr('src', '/uploads/images/bigoading.gif');

                    txtPicture.val('Loading...');
                    txtPicture.attr('disabled', true);
                    this.disable();

                },
                onComplete: function (file, response) {
                    thumb.load(function () {

                        thumb.unbind();

                    });
                    txtPicture.attr('disabled', false);
                    var resp = response;
                    resp = jQuery(resp).html();
                    thumb.attr('src', resp);
                    this.enable();

                    txtPicture.val(resp);

                }
            });
        });
    </script>

</asp:Content>

